Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
How to import sodium-plus directly into a .js file? "module does not provide an export named 'default'"

I would like to import sodium-plus to use within a .js file in a Chrome extension. The library's documentation only shows how to include the extension from an html file with a <script> tag. When I do that I get an error:

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'".

I tried to import directly through a .js file:

import SodiumPlus from "./sodium-plus.min.js";
(async function() {
    if (!window.sodium) window.sodium = await SodiumPlus.auto();

    // You can now use the sodium object here.

    // Just some example code to ensure it's running:
    let random = await sodium.randombytes_buf(32);
    let hash = await sodium.crypto_generichash('hello world');
    console.log({
        'random': random.toString('hex'),
        'hash': hash.toString('hex')
    });
})();

But received an error:

Uncaught SyntaxError: The requested module './sodium-plus.min.js' does not provide an export named 'default'

Is there any way to fix that? Alternatively, is there a similar library that would be easier to import into a .js file of a Chrome extension?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!